package ReviewTest;

import java.util.Scanner;

public class demo02 {
    public static void main(String[] args) {
        //定义一个数组
        int[] arr = new int[]{1, 2, 3, 4, 5, 6};
        System.out.println("请输入要查找的数字");
        //扫描器
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int index = -1;
        for (int i = 0; i < arr.length; i++) {
            if (num == arr[i]) {
                index = i;
                System.out.println(i);
            }
        }
        if (index < 0) {
            System.out.println("不存在");
        }
    }
}
